define([
    "UtilDir/util",
    "UtilDir/tool",
    "UtilDir/org/selectOrg",
    "UtilDir/searchBlock",
    "static/app/hddc/hddccjcommon/hddccjCommon",
    "Date","DateCN", "css!DateCss",
    "EasyUI","EasyUI-lang"
],function(Util, Tool, SelectOrg, SearchBlock,HddccjCommon){
    var getHddcGeologicalsvyplanninglineController = function(){
        return getServer() + "/hddc/hddcGeologicalsvyplanninglines";
    };
    var getHddcMainafsvyregionController = function(){
        return getServer() + "/hddc/hddcMainafsvyregions";
    };
    var getHddcMaterialpolygonlayerController = function(){
        return getServer() + "/hddc/hddcMaterialpolygonlayers";
    };
    var getHddcTargetregionController = function(){
        return getServer() + "/hddc/hddcTargetregions";
    };
    var getHddcWorkregionController = function(){
        return getServer() + "/hddc/hddcWorkregions";
    };

    //A1_InvestigationRegion(区域调查)
    //获取线路|面经纬度数组
    var getLonLatArray = function(LonLatString){
        var LonLatArray = [];//经纬度数组
        var strArray = LonLatString.split(";");
        if(strArray!=null && strArray.length>0){
            for(var i=0;i<strArray.length;i++){
                var str = strArray[i];
                var lonlatStrArray = str.split(",");
                if(lonlatStrArray!=null && lonlatStrArray.length==2){
                    var lonStr = lonlatStrArray[0];
                    var latStr = lonlatStrArray[1];
                    if(lonStr!="" && latStr!=""){
                        var lon = parseFloat(lonStr);
                        var lat = parseFloat(latStr);
                        if(lon>0 && lon<180 && lat>0 && lat<90){
                            //经纬度
                            var lonlat = [lon,lat];
                            //添加经纬度
                            LonLatArray.push(lonlat);
                        }
                    }
                }
            }
        }
        return LonLatArray;
    };

    //1查询地质调查规划路线-线
    var initQueryGeologicalSvyPlanningLineData = function () {
        console.log("1查询地质调查规划路线-线");
        var allLonLatArray = [];
        var allUuidArray = [];
        var allDataArray=[];
        $.ajax({
            url: getHddcGeologicalsvyplanninglineController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                for(var i=0;i<data.length;i++){
                    var LonLatString = data[i].extends5;//经纬度字符串
                    if(LonLatString!=null && LonLatString!=""){
                        var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                        //添加经纬度数组
                        allLonLatArray.push(LonLatArray);
                        //添加UUID
                        allUuidArray.push(data[i].uuid);
                    }
                }
                allDataArray = [allUuidArray,allLonLatArray];
            }
        });

        return allDataArray;
    };

    //2查询主要活动断层制图区-面
    var initQueryMainAFSvyRegionData = function () {
        console.log("2查询主要活动断层制图区-面");
        var allLonLatArray = [];
        var allUuidArray = [];
        var allDataArray=[];
        $.ajax({
            url: getHddcMainafsvyregionController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                for(var i=0;i<data.length;i++){
                    var LonLatString = data[i].extends5;//经纬度字符串
                    if(LonLatString!=null && LonLatString!=""){
                        var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                        //添加经纬度数组
                        allLonLatArray.push(LonLatArray);
                        //添加UUID
                        allUuidArray.push(data[i].uuid);
                    }
                }
                allDataArray = [allUuidArray,allLonLatArray];
            }
        });

        return allDataArray;
    };

    //3面状资料图层-面
    var initQueryMaterialPolygonLayerData = function () {
        console.log("3面状资料图层-面");
        var allLonLatArray = [];
        var allUuidArray = [];
        var allDataArray=[];
        $.ajax({
            url: getHddcMaterialpolygonlayerController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                for(var i=0;i<data.length;i++){
                    var LonLatString = data[i].extends5;//经纬度字符串
                    if(LonLatString!=null && LonLatString!=""){
                        var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                        //添加经纬度数组
                        allLonLatArray.push(LonLatArray);
                        //添加UUID
                        allUuidArray.push(data[i].uuid);
                    }
                }
                allDataArray = [allUuidArray,allLonLatArray];
            }
        });

        return allDataArray;
    };

    //4目标区-面
    var initQueryTargetRegionData = function () {
        console.log("4目标区-面");
        var allLonLatArray = [];
        var allUuidArray = [];
        var allDataArray=[];
        $.ajax({
            url: getHddcTargetregionController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                for(var i=0;i<data.length;i++){
                    var LonLatString = data[i].extends5;//经纬度字符串
                    if(LonLatString!=null && LonLatString!=""){
                        var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                        //添加经纬度数组
                        allLonLatArray.push(LonLatArray);
                        //添加UUID
                        allUuidArray.push(data[i].uuid);
                    }
                }
                allDataArray = [allUuidArray,allLonLatArray];
            }
        });

        return allDataArray;
    };

    //5工作区-面
    var initQueryWorkRegionData = function () {
        console.log("5工作区-面");
        var allLonLatArray = [];
        var allUuidArray = [];
        var allDataArray=[];
        $.ajax({
            url: getHddcWorkregionController() + "/queryAllSpaceData/",
            type: "get",
            async:true,
            success: function (data) {
                for(var i=0;i<data.length;i++){
                    var LonLatString = data[i].extends5;//经纬度字符串
                    if(LonLatString!=null && LonLatString!=""){
                        var LonLatArray = getLonLatArray(LonLatString);//获取经纬度数组
                        //添加经纬度数组
                        allLonLatArray.push(LonLatArray);
                        //添加UUID
                        allUuidArray.push(data[i].uuid);
                    }
                }
                allDataArray = [allUuidArray,allLonLatArray];
            }
        });

        return allDataArray;
    };

    return {
        initQueryGeologicalSvyPlanningLineData:initQueryGeologicalSvyPlanningLineData,
        initQueryMainAFSvyRegionData:initQueryMainAFSvyRegionData,
        initQueryMaterialPolygonLayerData:initQueryMaterialPolygonLayerData,
        initQueryTargetRegionData:initQueryTargetRegionData,
        initQueryWorkRegionData:initQueryWorkRegionData
    };
});
